#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void print(int arr[], int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
}

void swap(char* p1, char* p2, int width)
{
	char* tmp = *p1;
	*p1 = *p2;
	*p2 = tmp;
	p1++;
	p2++;

}

int cmp_qsort_bubble(const void* e1, const void* e2)
{
	return (*(int*)(e1)-*(int*)(e2));
}

void my_qsort(void* base, size_t n, size_t width, int(*cmp)(const void*, const void*))
{
	int i = 0;
	for (i = 0; i < n-1; i++)
	{
		int j = 0;
		for (j = 0; j < n - 1 - i; j++)
		{
			if (cmp((char*)base + j * width, (char*)base + (j + 1) * width) > 0)
			{
				swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
			}
		}
	}

}

int main()
{
	int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	my_qsort(arr, sz, sizeof(arr[0]), cmp_qsort_bubble);
	print(arr, sz);
	return 0;
}